package service;

import dao.Cardao;
import pojo.car;
import pojo.user;

import java.sql.SQLException;
import java.util.List;

public class Carservice {
    Cardao cardao=new Cardao();

    // 查询所有用户，一行显示一个用户
    public List<car> userList(){
        List<car> users = null;
        try {
            users=cardao.selectAll();
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        return users;
    }
    // 新增用户的方法
    public int addUser(car car){
        int i = 0;
        try {
            i = cardao.insert(car);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return i;
    }

    // 修改用户的方法
    public int updateUser(car car){
        int i = 0;
        try {
            i = cardao.update(car);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return i;
    }

    // 删除用户的方法
    public int deleteUser(car car){
        int i = 0;
        try {
            i = cardao.delete(car);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return i;
    }
    public List<car> select(String num){
        List<car> users = null;
        try {
            users=cardao.select(num);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        return users;
    }
}
